package com.lg.baselibrary.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by LiGang on 2017/5/28.
 */

public class BaseRecyclerViewHolder extends BaseViewHolder implements View.OnClickListener, View.OnLongClickListener {
    private OnItemClickListener onItemClickListener;
    private OnItemLongClickListener onItemLongClickListener;
    public BaseRecyclerViewHolder(Context context, View itemView) {
        super(context, itemView);
        itemView.setOnClickListener(this);
        itemView.setOnLongClickListener(this);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }
    public void setOnItemLongClickListener(OnItemLongClickListener onItemLongClickListener) {
        this.onItemLongClickListener = onItemLongClickListener;
    }
    @Override
    public void onClick(View v) {
        if(onItemClickListener != null){
            onItemClickListener.onItemClick(BaseRecyclerViewHolder.this,null,mItemView,getItemPosition());
        }
    }
    @Override
    public boolean onLongClick(View v) {
        if(onItemLongClickListener != null){
            return onItemLongClickListener.onItemLongClick(BaseRecyclerViewHolder.this,null,mItemView,getItemPosition());
        }
        return false;
    }
    public interface OnItemClickListener {
        void onItemClick(BaseViewHolder holder, ViewGroup parent, View itemView, int position);
    }
    public interface OnItemLongClickListener {
        boolean onItemLongClick(BaseViewHolder holder, ViewGroup parent, View itemView, int position);
    }
}
